<?php
defined('IN_XLP') or exit('Access Denied');
$Document = array(
    'pageid'   => 'order-cancel', //页面标示
    'pagename' => '还款失败', //当前页面名称
    'mycss'    => array(), //加载的css样式表
    'myjs'     => array(), //加载的js脚本
    'footerjs' => array(),
    'head'     => false, //加载头部文件
);
include getTpl('header', 'public');
?>
<style>.pt7{padding-top:7px;}</style>
<form style="width:600px;height:400px;" class="form-horizontal" method="post" id="processForm">
    <div class="form-group">
        <label class="col-sm-2 control-label">借贷编号</label>
        <div class="col-sm-5 pt7"><?php echo $order['order_sn']; ?></div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">申请时间</label>
        <div class="col-sm-5 pt7"><?php if($order['create_time']) echo date('Y-m-d H:i:s', $order['create_time']); ?></div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">失败原因</label>
        <div class="col-sm-5">
            <textarea name="reason" id="note" cols="30" rows="10" data-required="true" class="bg-focus form-control"></textarea>
            <div class="line line-dashed m-t-large"></div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-9 col-lg-offset-2">
            <input type="hidden" name="order_id" value="<?php echo $order['id']; ?>">
            <div class="col-sm-1"><button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button></div>
            <button type="button" class="btn btn-white col-md-offset-2" onclick="self.location.reload();">取消</button>
        </div>
    </div>
</form>
<script>
$(function(){
    $('#processForm').submit(function(){
        var note = $.trim($('#note').val());
        if(note==''){
            Msg.error('请输入还款失败原因');
            resetSubmit("#sub-ok",'提交');
            return false;
        }
        Msg.loading();
        $.post('<?php echo U("order/cancel_payment");?>',$(this).serialize(),function(result){
            Msg.hide();
            resetSubmit("#sub-ok",'提交');
            if(result.status==1){
                Msg.ok(result.info);
                self.location.reload();
            }else{
                Msg.error(result.info);
            }
        },'JSON');
        return false;
    });
});
</script>
</body>
</html>